package Econf_Audio;

import java.io.IOException;
import java.net.MalformedURLException;
 
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.Player;
 
public class Receveur_InFile_Serveur extends Thread{
  
		/**
           * @param args
           */
	// Attributs
    private static int portR;
	private static String loClient;
	
	// Constructeur
	public Receveur_InFile_Serveur(int portR) {
		this.portR = portR;
		loClient = "127.0.0.1";
	}
	

	// Methode init
          public void run() {
        	  

        	  
                  String url= "rtp://"+loClient+":"+portR+"/audio/1";
                   
                  MediaLocator mrl= new MediaLocator(url);
                  
                  if (mrl == null) {
                          System.err.println("Can't build MRL for RTP");
                          System.exit(-1);
                  }
                  
                  // create a processor
//                  Proc
//            	  DataSink sink;
//            	  MediaLocator dest = new MediaLocator(file://newfile.wav);
//            	  try{
//            	  sink = Manager.createDataSink(p.getDataOutput(), dest); 
//            	  sink.open();
//            	  sink.start();
//            	  } catch (Exception) {}
                  
//                  // Create a player for this rtp session
//                  Player player = null;
//                  try {
//                          player = Manager.createPlayer(mrl);
//                  } catch (NoPlayerException e) {
//                          System.err.println("Error:" + e);
//                          System.exit(-1);
//                  } catch (MalformedURLException e) {
//                          System.err.println("Error:" + e);
//                          System.exit(-1);
//                  } catch (IOException e) {
//                          System.err.println("Error:" + e);
//                          System.exit(-1);
//                 }
                  
//                 if (player != null) {
//                        System.out.println("Player created.");
//                        player.realize();
// //               wait for realizing
//                          while (player.getState() != Player.Realized){
//                                  try {
//                                          Thread.sleep(10);
//                                } catch (InterruptedException e) {
//                                          e.printStackTrace();
//                                  }
//                          }
//                          player.start();
//                  } else {
//                          System.err.println("Player doesn't created.");
//                          System.exit(-1);
//                  }
          }
  
}
